package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.come.entity.Goodstable;
import org.come.mouslisten.MyOptionalMouslisten;
import org.come.mouslisten.MyOptionalMouslisten1;
import org.come.until.CutButtonImage;
import org.come.until.UserMessUntil;
import org.come.until.ZipUtils;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.RoleCaoZuoBtn;
import com.tool.tcp.Sprite;
import com.tool.tcp.SpriteFactory;
import com.tool.tcpimg.UIUtils;
/**
 * 自选礼包
 * @author admin
 *
 */
public class MyOptionalJpanel1 extends JPanel {
    
	private static RoleCaoZuoBtn[] purchasebtn,purchasebtn1;//
	private static FormsOnOffBtn offBtn;//
    public static String msg = "";
    public static JLabel[] labGoodsImgsx = new JLabel[15],goodsname = new JLabel[15];
    public static JLabel labGoodsImgwx,labGoodsImgwsx,yidong,numbers;
    private static JTextField findName,findName1;
    public static MyOptionalMouslisten1[] flipMouslisten = new MyOptionalMouslisten1[15];
    public static MyOptionalMouslisten1[] flipGoodsMouslisten = new MyOptionalMouslisten1[15];
    public static Goodstable goods;
    public static Goodstable zhjgood = new Goodstable();
    public static int sxX;
    public static int sxY;
    public static int it = 4000;
    public static int dz = -1;
    public static boolean b = false;
    public static boolean start = false;
    public static List<String> godList;
    public static List<Goodstable> goodsList;
    public static Sprite drawfp = SpriteFactory.VloadSprite("resource/loginButton/drawfp.tcp", null);
    
    public MyOptionalJpanel1() {
        this.setPreferredSize(new Dimension(554,223));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);
        purchasebtn = new RoleCaoZuoBtn[15];
        Font font = new Font("楷体", 1, 16);
        for(int i=0;i<15;i++) {
    		goodsname[i] = new JLabel();
        	purchasebtn[i] = new RoleCaoZuoBtn("inkImg/button/领取.png", 1, UIUtils.COLOR_BLACK, font, "", 3021+i);
        	flipMouslisten[i] = new MyOptionalMouslisten1(i, this, 1);
        	purchasebtn[i].setBounds(90*i+60, 150, 70,60);
    		goodsname[i].setBounds(95*i+40, 120, 190,90);
            purchasebtn[i].setVisible(true);
            this.add(purchasebtn[i]);
        }
        showViewData();
    }
    
    /**展示物品*/
    public void showViewData(){
    	Font font = new Font("楷体",1,14);
    	goodsList = new ArrayList<Goodstable>();
    	labGoodsImgsx = new JLabel[15];
    	for(int i=0;i<labGoodsImgsx.length;i++) {
    		if(labGoodsImgsx[i]!=null) {
    			this.remove(labGoodsImgsx[i]);
    		}
    		if(goodsname[i]!=null) {
    			this.remove(goodsname[i]);
    		}
    	}
    	for(int i=0;i<labGoodsImgsx.length;i++) {
    		labGoodsImgsx[i] = new JLabel();
    		Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(godList.get(i)));
    		goodsList.add(goodstable);
    		goodsname[i].setFont(font);
    		goodsname[i].setForeground(UIUtils.COLOR_BLACK[0]);
    		labGoodsImgsx[i].setIcon(CutButtonImage.getImage("img/item/" + goodstable.getSkin() + ".png", 70,70));
    		labGoodsImgsx[i].setBounds(90*i+60, 45, 90,90);
    		flipGoodsMouslisten[i] = new MyOptionalMouslisten1(i, this, 1);
            labGoodsImgsx[i].addMouseListener(flipGoodsMouslisten[i]);
    		goodsname[i].setText(goodstable.getGoodsname());
    		labGoodsImgsx[i].setVisible(true);
    		this.add(labGoodsImgsx[i]);
    	}
    }
    
	private ImageIcon icon2 = new ImageIcon("inkImg/background/装备自选卡.png");

    @Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.drawImage(icon2.getImage(), 0, 0, 554, 223, this);
	}
    
    public static JTextField getFindName() {
		return findName;
	}

	public static void setFindName(JTextField findName) {
		MyOptionalJpanel1.findName = findName;
	}
	
}

